package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.HotelDoc;
import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParam;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController//controller+responsebody
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    IHotelService iHotelService;

    //接收一个前端传过来的post请求
    @PostMapping("/list")
    public PageResult searchList(@RequestBody RequestParam param) {
        System.out.println(param);
        PageResult search = iHotelService.search(param);
        System.out.println(search);
        return search;
    }
    @PostMapping("/filters")
    public Map<String,List<String>> getFilters(@RequestBody RequestParam param){
        return iHotelService.getFilters(param);
    }
}
